<script setup lang="ts">
import { useCateGoryStore } from '@/stores/modules/category'
import type { CategoryItem } from '@/types/home'
//定义props接收数据
defineProps<{
  list: CategoryItem[]
}>()
// 获取分类id的仓库
const CateGoryStore = useCateGoryStore()
// 跳转到tabbar
const changeToCategory = (index: number) => {
  CateGoryStore.changeCateGory(index)
  uni.switchTab({ url: `/pages/category/category` })
}
</script>

<template>
  <view class="category">
    <view
      class="category-item"
      hover-class="none"
      @tap="changeToCategory(index)"
      v-for="(item, index) in list"
      :key="item.id"
    >
      <image class="icon" :src="item.icon"></image>
      <text class="text">{{ item.name }}</text>
    </view>
  </view>
</template>

<style lang="scss">
@import './style/CategoryPanel.scss';
</style>
